package com.yanboo.generator.domain;

import com.yanboo.common.base.BaseEntity;
import com.yanboo.common.constant.DataFilterConstant;
import com.yanboo.generator.constant.DbType;
import jakarta.persistence.CascadeType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.*;

import java.util.List;

import jakarta.persistence.*;

import java.io.Serializable;

@Getter
@Setter
@Entity
@DynamicInsert
@DynamicUpdate
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "project_info")
//数据过滤示例
@Filters(@Filter(name = DataFilterConstant.FILTER, condition = DataFilterConstant.CONDITION))
public class ProjectInfo extends BaseEntity implements Serializable {

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "db_driver_id", referencedColumnName = "id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    //@Filters(@Filter(name = DataFilterConstant.FILTER, condition = DataFilterConstant.CONDITION))
    private DbDriver dbDriver;

//    @OneToMany(mappedBy = "projectInfo")
//    @org.hibernate.annotations.ForeignKey(name = "none")
//    private List<GenConfig> genConfig;

    private String name;

    private String code;

    private String jdbcUrl;

    private String username;

    private String password;

    @Enumerated(value = EnumType.STRING)
    private DbType dbType;
}
